<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/9/30 0030
  Time: 上午 10:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
    <script src="../../layui-v2.2.5/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layui-v2.2.5/layui/css/layui.css" media="all">
</head>
<body>

<input placeholder="请输入名称或者电话号码" id="key" value="${key}"
           style="height: 32px;margin-top: 0.5%; margin-left: 25%;font-size: 24px">
<i class="layui-icon" style="font-size: 30px;" onclick="search()">&#xe615;</i>
<script>
    function search() {
        console.log("搜索事件");
        window.location.href="/marketing/statisticsMember?activityId=${activityId}&key="+$("#key").val();
    }
</script>


<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right: 100px"  href="javascript:location.replace(location.href);"
   title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
<br><br>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script>
    layui.use('table', function(){
        var table = layui.table
            ,form = layui.form;
        table.render({
            elem: '#test'
            ,url:'/marketing/statistcsMemberData?activityId=${activityId}'+"&key="+$("#key").val()
            ,cellMinWidth: 80
            ,cols: [[
                {type:'numbers'}
                ,{field:'id', title:'ID', width:280, }
                ,{field:'name', title:'会员名',width:100,}
                ,{field:'parentName', title:'上级会员',width:100,}
                ,{field:'createTime', title: '创建时间', width:200,}
                ,{field:'grade', title:'会员等级',width:100,}
                ,{field:'rebateMoney', title:'返利总金额',width:100,}
                ,{field:'oneSonMember', title: '下级会员人数', width:150,}
                ,{fixed: 'right', title:'优惠券',width:150,toolbar:'#voucher'}
                ,{fixed: 'right', title:'返利级记录',width:150,toolbar:'#rebate'}
            ]]
            ,page:true
        });



        table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if(layEvent === 'voucher'){ //优惠券
                console.log(data);
                layer.open({
                    type: 2,
                    title:"会员优惠券",
                    shadeClose:true,
                    area: ['90%', '90%'],
                    content: '/marketing/toMemberVoucher?id='+data.id,
                    end:function () {
                        //window.location.reload();
                    }
                });
            }else if (layEvent === 'rebate'){
                console.log("返利记录");
            }
        });

    });



</script>

<script type="text/html" id="voucher">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="voucher">会员优惠券</button>
    </div>
</script>
<script type="text/html" id="rebate">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="rebate">返利记录</button>
    </div>
</script>

</body>
</html>
